
import java.util.*;


/**
 *
 * @author Indra
 */
public class Menu {
    
    public static void main(String[]args){
    
        Menu a = new Menu();
        a.pilihan();
    }
    
    public void pilihan(){
        System.out.println("----------------------------------");
        System.out.println("--APLIKASI KONVERSI JARAK & SUHU--");
        System.out.println("----------------------------------");
        System.out.println("- 1.KONVERSI KM ke MILES         -");
        System.out.println("- 2.KONVERSI MILES ke KM         -");
        System.out.println("- 3.KONVERSI CELCIUS ke FARENHEIT-");
        System.out.println("- 4.KONVERSI FARENHEIT ke CELCIUS-");
        System.out.println("- 5.KELUAR                       -");
        System.out.println("----------------------------------");
        Scanner in = new Scanner(System.in);
        ConvertJarak jarak = new ConvertJarak();
        ConvertSuhu suhu = new ConvertSuhu();
        System.out.print("Pilih Menu : ");
        int pilih = in.nextInt();
        double var;
        double hasil;
        switch(pilih){
            case 1 : 
                System.out.print("Masukkan variabel :");
                var = in.nextDouble();
                hasil=jarak.KMtoMiles(var);
                System.out.println(var+" km = "+hasil+" Miles");
                pilihan();
                break;
            case 2 :
                System.out.print("Masukkan variabel :");
                var = in.nextDouble();
                hasil=jarak.MilestoKM(var);
                System.out.println(var+" Miles = "+hasil+" km");
                pilihan();
                break;
            case 3 :
                System.out.print("Masukkan variabel :");
                var = in.nextDouble();
                hasil=suhu.CtoF(var);
                System.out.println(var+" Celcius = "+hasil+" Farenheit");
                pilihan();
                break;
            case 4 : 
                System.out.print("Masukkan variabel :");
                var = in.nextDouble();
                hasil=suhu.FtoC(var);
                System.out.println(var+" Farenheit = "+hasil+" Celcius");
                pilihan();
                break;
            case 5 :
                System.exit(0);
                break;
            default : 
                break;
        }
    }
}
